import java.util.Arrays;
import java.util.Comparator;

public class Practice03 {
    public static void main(String[] args) {
        //设计程序按照各个学生的 Java 成绩进行排序 ( 降序 )
        String[] names = {"安琪拉", "王昭君", "蔡文姬", "妲己", "张良"};
        String[] courses = {"C++", "Java", "Python"};
        int[][] scores = {
                {90, 89, 75},
                {59, 40, 100},
                {100, 99, 80},
                {80, 61, 61},
                {60, 100, 99},
        };
            for (int i = 0; i < scores.length ; i++) {
                for (int j = 0; j < scores.length -1 ; j++) {
                    if (scores[j][1] < scores[j + 1][1]) {
                        //成绩进行交换
                        int[] temp = scores[j];
                        scores[j] = scores[j + 1];
                        scores[j + 1] = temp;
                        //名字进行交换
                        String temp1 = names[j];
                        names[j] = names[j + 1];
                        names[j + 1] = temp1;
                    }
                }
            }
        System.out.println("按照各个学生的 Java 成绩进行排序 ( 降序 )");
        for (int i = 0; i < scores.length; i++) {
            System.out.print(names[i] + " => "); // 输出学生姓名
            for (int j = 0; j < scores[i].length; j++) {
                System.out.print(courses[j] + ":");// 输出课程名称
                System.out.print(scores[i][j]); // 输出课程成绩
                if (j < scores[i].length - 1) {
                    System.out.print(" , ");
                }
            }
            System.out.println();
        }
    }
}